
public class Customer
{
	/**
	 * @uml.property  name="position"
	 */
	private int position; // Queue position
	/**
	 * @uml.property  name="name"
	 * @uml.associationEnd  multiplicity="(1 1)"
	 */
	private Name name; // First/Middle/Last name of customer
	/**
	 * @uml.property  name="parcelId"
	 */
	private String parcelId; // Parcel ID customer is looking for

    /**
     * Constructor: create customer object from passed arguments
     * @param position int position of customer in queue (starting at 1)
     * @param name Name object containing customer name
     * @param parcelId String ID of parcel customer is looking for 
     */
    public Customer (int position, Name name, String parcelId) {
    	this.position = position;
    	this.name = name;
    	this.parcelId = parcelId;
    }

    /**
     * Constructor: create customer object from string
	 * Processes line, extracts data, creates customer object and adds to list
	 * Checks for missing items and invalid data
	 * @param line String to be processed, in format {POSITION:\\d+},{NAME:[A-Za-z ]+},{PARCEL ID:{PARCEL TYPE:[A-Z]}\\d+}
	 */
    public Customer (String line) {
		try {
			// create variables to hold the data from each comma-separated section of the input line
			// split the input line into an array of Strings
			String parts [] = line.split(",");
			
			// Customer Queue position - int
			this.position = Integer.parseInt(parts[0]);
			
			// Customer Name - String
			// Processes string which can contain up to three names (first, middle, last)
			// separated by spaces, and creates a Name object 
			this.name = new Name(parts[1]);
			
			// Customer Parcel ID - String
			this.parcelId = parts[2];
		}

		//for these two formatting errors, ignore lines in error and try and carry on

		//this catches trying to convert a String to an integer
		catch (NumberFormatException nfe) {
			String error = "Number conversion error in '" + line + "'  - " + nfe.getMessage();
			error += "\n\nPlease check the Customer input file; all lines should be in the following format:\n";
			error += "{POSITION:\\d+},{NAME:[A-Za-z ]+},{PARCEL ID:{PARCEL TYPE:[A-Z]}\\d+}";
			System.out.println(error);
			System.exit(1);
		}
		//this catches missing items if only one or two items
		//other omissions will result in other errors
		catch (ArrayIndexOutOfBoundsException air) {
			String error = "Not enough items in  : '" + line + "' index position : " + air.getMessage();
			error += "\n\nPlease check the Customer input file; all lines should be in the following format:\n";
			error += "{POSITION:\\d+},{NAME:[A-Za-z ]+},{PARCEL ID:{PARCEL TYPE:[A-Z]}\\d+}";
			System.out.println(error);
			System.exit(1);
		}

	}
    

    // Basic getters
 	/**
	 * @return
	 * @uml.property  name="position"
	 */
 	public int getPosition() {
		return position;
	}
 	/**
	 * @return
	 * @uml.property  name="name"
	 */
 	public Name getName() {
		return name;
	}
 	/**
	 * @return
	 * @uml.property  name="parcelId"
	 */
 	public String getParcelId() {
		return parcelId;
	}
 	
 	// Basic setters
 	/**
	 * @param  position
	 * @uml.property  name="position"
	 */
 	public void setPosition(int position) {
		this.position = position;
	}
 	/**
	 * @param  name
	 * @uml.property  name="name"
	 */
 	public void setName(Name name) {
		this.name = name;
	}
 	/**
	 * @param  parcelId
	 * @uml.property  name="parcelId"
	 */
 	public void setParcelId(String parcelId) {
		this.parcelId = parcelId;
	}
	/**
	 * @uml.property  name="customerQueue"
	 * @uml.associationEnd  inverse="customer:CustomerQueue"
	 */
	private CustomerQueue customerQueue;

	/**
	 * Getter of the property <tt>customerQueue</tt>
	 * @return  Returns the customerQueue.
	 * @uml.property  name="customerQueue"
	 */
	public CustomerQueue getCustomerQueue() {
		return customerQueue;
	}

	/**
	 * Setter of the property <tt>customerQueue</tt>
	 * @param customerQueue  The customerQueue to set.
	 * @uml.property  name="customerQueue"
	 */
	public void setCustomerQueue(CustomerQueue customerQueue) {
		this.customerQueue = customerQueue;
	}
	/**
	 * @uml.property  name="name1"
	 * @uml.associationEnd  inverse="customer:Name"
	 */
	private Name name1;

	/**
	 * Getter of the property <tt>name1</tt>
	 * @return  Returns the name1.
	 * @uml.property  name="name1"
	 */
	public Name getName1() {
		return name1;
	}

	/**
	 * Setter of the property <tt>name1</tt>
	 * @param name1  The name1 to set.
	 * @uml.property  name="name1"
	 */
	public void setName1(Name name1) {
		this.name1 = name1;
	}
}